<?php
/**
 * AclResources table data gateway
 *
 * @version $Id: AclResources.php 73 2010-04-25 00:30:44Z yingkuang.chen@gmail.com $
 * @license New BSD License
 * @uses Zend_Db_Table_Abstract
 * @package default
 * @subpackage Model
 */
class Default_Model_DbTable_AclResources extends Zend_Db_Table_Abstract
{

	protected $_name = 'acl_resources';

	protected $_promary = 'id';


    public function getResource()
    {
        // remove default resource
        $where = array('id<>?' => 'default');
        return $this->fetchAll($where,'sort');
    }

   public function getChildCount($id)
    {
    	$query = $this->getAdapter()->select()->from('acl_resources', array('cc'=>'count(*)'))->where("parent_id='$id'");
    	//$query = $this->getAdapter()->select()-"SELECT COUNT(*) AS cc FROM acl_resources WHERE parent_id='$id'";
	//	echo $query;
    	$res = $this->getAdapter()->fetchRow($query);
    	return $res['cc'];
    }
}
